#include "chatInputText.h"
#include <iostream>
#include <sstream>

chatInputText::chatInputText(QWidget *widget) : QTextEdit(widget)
{
}

void
chatInputText::keyPressEvent(QKeyEvent *event)
{
	// if user presses enter then we cut the text and paste it into chat window
	if(event->key()==Qt::Key_Return)
	{

		eventStore es;
		es.message = this->toPlainText().toStdString();
		es.tag = "You";
		es.type=1;
		pthread_mutex_lock(&listener::mutex);
		listener::eventQueue.push(es);
		pthread_mutex_unlock(&listener::mutex);
		//listener_->yieldSendMessage(this->toPlainText().toStdString());
		clear();
	}
	// otherwise we propagate the event to the parent's handler
	else QTextEdit::keyPressEvent(event);
}

